import json
from cmdb.api.session import session_get
from cmdb.api.session import session_set

def json_obj(req):
    try:
        token = req.POST.get('token', 'null')
        data =  json.loads(session_get(token, 'data'))
        session_set(token, 'data', None)
        return data, 'json ok'

    except BaseException as e:
        return None, e.__str__()